home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / fractal / kaos.lha / userlib / userds1_def.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-02-06  |  3.1 KB  |  115 lines

  1. /*
  2. Initialize all parameters for a given dynamical system to be installed
  3. Parameters are assigned to the default values before this program is called.
  4. -----------------------------------------------------------------------
  5. This is a GENERIC subroutine. If you want, you can change
  6. the name string "userds1" to a proper one globally in this program
  7. but then you need to change the same strings in the header file defining
  8. the current class of dynamical systems.
  9. */
  10.  
  11. /*
  12. Example 1: vector field with no periodic variable
  13. */
  14.  
  15. #include "model.h"
  16.  
  17. int userds1_init()
  18. {
  19.  
  20.     /* title label */
  21.     title_label = "Coupled Henon Map";
  22.  
  23.     /* mapping toggle: 1: map, 0: vector field */
  24.     mapping_on = 1;
  25.     /* inverse toggle: vector field: always 1,
  26.        maps: 1=explicit inverse is defined, 0=otherwise  */      /* mrm  (2/6/90) */
  27.     inverse_on = 1;
  28.     /* jacobian toggle: 1=Jacobian is explicitly given, 0=otherwise */
  29.     fderiv_on = 0;
  30.     /* polar toggle: 1=enable polar coordinate feature, 0=otherwise */
  31.     enable_polar = 0;
  32.     /* period toggle: 1=enable periodicity of phase space, 0=otherwise */
  33.     enable_period = 0;
  34.  
  35.     /* phase space dimension */
  36.     var_dim = 4;
  37.     /* parameter space dimension */
  38.     param_dim = 3;
  39.     /* function space dimension */
  40.     func_dim = 2;
  41.  
  42.     (void) malloc_init();
  43.  
  44.     /* primary phase space variable label (DIM=var_dim)*/
  45.     var_label[0] = "x";
  46.     var_label[1] = "y";
  47.     var_label[2] = "u";
  48.     var_label[3] = "v";
  49.     /* parameter variable label (DIM=param_dim)*/
  50.     param_label[0] = "b";
  51.     param_label[1] = "k";
  52.     param_label[2] = "c";
  53.     /* function variable label (DIM=func_dim)*/
  54.     func_label[0] = "Undefined";
  55.     func_label[1] = "Undefined";
  56.  
  57.     /* starting parameter values (DIM=param_dim)*/
  58.     param[0] = 0;
  59.     param[1] = 1.3;
  60.     param[2] = 0.01;
  61.  
  62.     /* starting primary phase space variable values (DIM=param_dim)*/
  63.     var_i[0] = 0;
  64.     var_i[1] = 0;
  65.     var_i[2] = 0;
  66.     var_i[3] = 0;
  67.  
  68.     /* starting bounds of parameter window box */
  69.     param_min[0]= 0; param_max[0]= 1;
  70.     param_min[1]= 0; param_max[1]= 5;
  71.     param_min[1]= 0; param_max[1]= 1;
  72.  
  73.     /* starting bounds of primary phase space window box */
  74.     var_min[0]= -5; var_max[0]= 5;
  75.     var_min[1]= -5; var_max[1]= 5;
  76.     var_min[2]= -5; var_max[2]= 5;
  77.     var_min[3]= -5; var_max[3]= 5;
  78.  
  79.     /* dynamical system and function pointer assignments */
  80.     f_p = userds1_f;
  81.     func_p = userds1_func;
  82. }
  83. /*
  84. second user dynamical system 
  85. */
  86.     
  87. int userds1_f(f,index,x,p,t,dim)
  88. int index,dim;
  89. double f[],x[],p[],t;
  90. {
  91.     if(index==1){
  92.         f[0] = -p[0] * x[1] - p[1] * x[0] - (1 + p[1]) * x[0] * x[0] + p[2] * x[2];;
  93.         f[2] = -p[0] * x[3] - p[1] * x[2] - (1 + p[1]) * x[2] * x[2] + p[2] * x[0];;
  94.         f[1] = x[0] + p[1] * f[0] + (1 + p[1]) * f[0] * f[0] - p[2] * f[2];;
  95.         f[3] = x[2] + p[1] * f[2] + (1 + p[1]) * f[2] * f[2] - p[2] * f[0];;
  96.     }
  97.     else if (index==0){
  98.         f[0] = -p[0] * x[1] - p[1] * x[0] - (1 + p[1]) * x[0] * x[0] + p[2] * x[2];;
  99.         f[2] = -p[0] * x[3] - p[1] * x[2] - (1 + p[1]) * x[2] * x[2] + p[2] * x[0];;
  100.         f[1] = x[0] + p[1] * f[0] + (1 + p[1]) * f[0] * f[0] - p[2] * f[2];;
  101.         f[3] = x[2] + p[1] * f[2] + (1 + p[1]) * f[2] * f[2] - p[2] * f[0];;
  102.     }
  103. }
  104. /*
  105. second user function subroutine
  106. */
  107.  
  108. int userds1_func(f,x,p,t,dim)
  109. double f[],x[],p[],t;
  110. int dim;
  111. {
  112.     f[0] = 0;
  113.     f[1] = 0;
  114. }
  115.